﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Protobuf_Gui.Domain
{
    [Serializable]
    public class ProtocolException : Exception
    {
        public List<ProtocolElement> DuplicatedElements { get; private set; }

        public string FieldName { get; set; }

        public ProtocolException():base()
        {
            DuplicatedElements = new List<ProtocolElement>();
        }

        public ProtocolException(string message) : base(message)
        {
            DuplicatedElements = new List<ProtocolElement>();
        }

        public ProtocolException(string message, Exception inner) : base(message, inner)
        {
            DuplicatedElements = new List<ProtocolElement>();
        }

        public void AddDuplicated(ProtocolElement element)
        {
            DuplicatedElements.Add(element);
        }

        protected ProtocolException(
            SerializationInfo info,
            StreamingContext context) : base(info, context)
        {
        }
    }
}